<extend name="Public/index" />
<block name="main">
    <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/weber/webuploader.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/weber/style.css" />
    <style type="text/css">
        .block{
            display: block;
        }
        .none{
            display: none;
        }
        /*#form{*/
        /*display: block;*/
        /*}*/
    </style>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    DataTables Advanced Tables
                </div>

                <!-- /.panel-heading -->
                <div class="panel-body">
                    <button id="add" class="btn btn btn-primary" style="margin-bottom: 10px">添加新的图片</button>

                    <div style="margin-bottom: 30px;" class="row" style="" id="Doadd">
                        <div class="col-lg-12" style="border-bottom: 2px solid #ccc;padding: 10px";>
                            <div id="wrapper" class="upload">
                                <div id="container">
                                    <!--头部，相册选择和格式选择-->

                                    <div id="uploader">
                                        <div class="queueList">
                                            <div id="dndArea" class="placeholder">
                                                <div id="filePicker"></div>
                                                <p>或将照片拖到这里，单次最多可选300张</p>
                                            </div>
                                        </div>
                                        <div class="statusBar">
                                            <div class="progress">
                                                <span class="text">0%</span>
                                                <span class="percentage"></span>
                                            </div><div class="info"></div>
                                            <div class="btns">
                                                <div id="filePicker2"></div><div class="uploadBtn">开始上传</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <form role="form" id="form" action='__URL__/Pic/id/{$Think.get.id}/t/add' enctype="multipart/form-data" method="POST">
                                <div class="form-group">
                                    <input type="hidden" value="{$Think.get.id}" name="id">
                                    <label>图片</label>
                                    <input name="file" type="file">
                                </div>
                                <button type="submit" class="btn btn-default">Submit Button</button>
                                <button type="reset" class="btn btn-default">Reset Button</button>
                            </form>
                        </div>
                    </div>
                    <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                        <tr>
                            <th>NO.</th>
                            <th>图片</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach name="list" item="vo" >
                            <tr class="odd gradeX">
                                <td>{++$i}</td>
                                <td><img width="200px" src="__ROOT__{$vo.img}"></td>
                                <td style='text-align:center;' class="center">
                                    <a href="{:U('picdel',array('id'=>$vo['id']))}">删除</a> |
                                    <a href="#" onclick="update({$vo.id})">修改</a>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
</block>
<block name='js'>

    <!-- <script type="text/javascript">window.url = '__URL__/Pic'</script>-->
    <!-- ue_end -->
    <script type="text/javascript" src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript">
        var No = 1;
        window.url = '__URL__/pic/id/{$Think.get.id}/t/add';
        $('#add').click(function(){

            $('#form').attr('action','__URL__/pic/t/add');
            $('#form input').empty();
            if ($(this).html() == '取消') {
                $(this).html('添加新的图片');
                $('#Doadd').hide(); return ;
            }
            $(this).html('取消');
            $('.upload').addClass('block');
            $('.upload').removeClass('none');

            $('#Doadd').show();

        })

        function update(id)
        {
            $('#form').attr('action','__URL__/pic/t/update');
            $('#form input').val('');
            $('#add').html('取消');
            $('#Doadd').show();
            $('.upload').addClass('none');
            $('.upload').removeClass('block');
            $('input[name=id]').val(id)
            $('body,html').animate({'scrollTop':0},100)
        }

        // var t = $('#dataTables-example').DataTable(

        // );
    </script>
    <script type="text/javascript" src="__PUBLIC__/weber/webuploader.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/weber/upload.js"></script>
</block>